<?php
class SP_Database_BaseContainer
{
	var $name;
	var $host='localhost';
	var $encoding='utf8';
	var $type='Mysql';
	var $root;
	var $reader;
	var $writer;
	private $root_base;
	private $reader_base;
	private $writer_base;
	
	
	
	public function setRoot($name,$pass)
	{
		$this->root['name']=$name;
		$this->root['pass']=$pass;
	}
	
	public function setReader($name,$pass)
	{
		$this->reader['name']=$name;
		$this->reader['pass']=$pass;
	}
	
	public function setWriter($name,$pass)
	{
		$this->writer['name']=$name;
		$this->writer['pass']=$pass;
	}
	
	public function getRoot()
	{
		
		if( !$this->root_base )
		{
			$class='SP_Database_'.$this->type.'Abstract';
			$this->root_base = new $class($this->name,$this->root['name'],$this->root['pass'],$this->host);
			$this->root_base->setEncoding($this->encoding);
		}
		return $this->root_base;
	}
	
	public function getReader()
	{
		if( !$this->reader_base )
		{
			$class='SP_Database_'.$this->type.'Abstract';
			$this->reader_base = new $class($this->name,$this->reader['name'],$this->reader['pass'],$this->host);
			$this->reader_base->setEncoding($this->encoding);
		}
		return $this->reader_base;
	}
	
	public function getWriter()
	{
		if( !$this->writer_base )
		{
			$class='SP_Database_'.$this->type.'Abstract';
			$this->writer_base = new $class($this->name,$this->writer['name'],$this->writer['pass'],$this->host);
			$this->writer_base->setEncoding($this->encoding);
		}
		return $this->writer_base;
	}
	
}